]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot: Split out disabling cast button
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 30 Jan 2024 18:56:42 +0000 (19:56 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 1 Feb 2024 12:17:43 +0000 (12:17 +0000)
Screencasts can be disabled for various reasons:

 1. the service is not available (missing plugin etc.)
 2. screencasts are not allowed by the session mode
    (lock screen etc.)
 3. the UI is invoked in screenshot-only mode (portal)

Currently each of those conditions is handled in a different
code path, which means that later conditions can re-enable
the button.

There's also an inconsistency whether disabling the button
is done via visibility or reactivity, which still allows
toggling the hidden button via shortcuts (although a hidden
button means that screencasts aren't supported at all, so
nothing will be recorded in that case).

Address this by updating the button from a dedicated function.

Fixes: 671df28a50 ("screenshot: Only handle mode-switch shortcut when
supported")

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7358
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3155>

js/ui/screenshot.js

index e5b50604db0c27f5d155fdda130cc1da42e7d932..f204d383df07dcb78816ac29e5486921177e0cb4 100644 (file)
@@ -1083,6 +1083,7 @@ export const ScreenshotUI = GObject.registerClass({
 
         this._screencastInProgress = false;
         this._screencastSupported = false;
+        this._currentMode = UIMode.SCREENSHOT;
 
         this._screencastProxy = new ScreencastProxy(
             Gio.DBus.session,
@@ -1095,7 +1096,7 @@ export const ScreenshotUI = GObject.registerClass({
                 }
 
                 this._screencastSupported = this._screencastProxy.ScreencastSupported;
-                this._castButton.visible = this._screencastSupported;
+                this._syncCastButton();
             });
 
         this._screencastProxy.connectSignal('Error',
@@ -1447,7 +1448,15 @@ export const ScreenshotUI = GObject.registerClass({
 
     _sessionUpdated() {
         this.close(true);
-        this._castButton.reactive = Main.sessionMode.allowScreencast;
+    }
+
+    _syncCastButton() {
+        const visible = this._screencastSupported;
+        const reactive = visible &&
+            this._currentMode !== UIMode.SCREENSHOT_ONLY &&
+            Main.sessionMode.allowScreencast;
+
+        this._castButton.set({visible, reactive});
     }
 
     _syncWindowButtonSensitivity() {
@@ -1549,8 +1558,9 @@ export const ScreenshotUI = GObject.registerClass({
         if (mode === UIMode.SCREENCAST && !this._screencastSupported)
             return;
 
+        this._currentMode = mode;
         this._castButton.checked = mode === UIMode.SCREENCAST;
-        this._castButton.reactive = mode !== UIMode.SCREENSHOT_ONLY;
+        this._syncCastButton();
 
         if (!this.visible) {
             // Screenshot UI is opening from completely closed state